{include file="common/pc/header" title="定时任务编辑" /}

<form class="layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label">任务标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" required value="{$task.title}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">任务状态</label>
        <div class="layui-input-block">
            <input type="radio" name="state" value="1" title="正常运行" {$task.state == 1 ? 'checked' : ''}>
            <input type="radio" name="state" value="0" title="暂停" {$task.state == 0 ? 'checked' : ''}>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">cron表达式</label>
        <div class="layui-input-block">
            <input type="text" name="cron" required  value="{$task.cron}" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">超时秒数</label>
        <div class="layui-input-block">
            <input type="text" name="timeout" required  value="{$task.timeout}" lay-verify="number" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">是否可重入</label>
        <div class="layui-input-block">
            <input type="radio" name="overlap" value="1" title="是" {$task.overlap == 1 ? 'checked' : ''}>
            <input type="radio" name="overlap" value="0" title="否" {$task.overlap == 0 ? 'checked' : ''}>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="save">保存</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(save)', function(data){
            data.field.id = {$task.id};
            $.post('update', data.field, function(res) {
                if (res.code == 1) {
                    layer.alert(res.msg, function () {
                        document.location.reload();
                    });
                } else {
                    layer.alert(res.msg);
                }
            });
            return false;
        });
    });
</script>

{include file="common/pc/footer"/}